package function

import scala.:+
import scala.collection.mutable.ArrayBuffer

class Array_Test {

}

object Array_Test {
  def main(args: Array[String]): Unit = {
    val arr1: Array[Int] = new Array[Int](3)
    val arr2: Array[Int] = Array(1, 2, 3)
    println(arr1(1))
    println(arr2(1))
    arr1(1) = 4
    arr2.update(0, 11)
    println(arr1(1))
    println(arr2(0))
    println(arr2.mkString("-"))
    println(arr2.max)
    println(arr2.sum)
    val arr3: Array[Int] = arr2.+:(11)

    val arr4 = 8 +: 9 +: arr3 :+ 5
    println(arr3.mkString(","))
    println(arr2.mkString(","))
    for(i<-0 to arr4.length) print(i+"-")
    println("=================")
    val ints1 = new ArrayBuffer[Int]()
    val ints2: ArrayBuffer[Int] = ArrayBuffer[Int](1, 2, 3, 4, 5, 6, 767, 68)
    println(ints2(1))
//    println(ints1(1))
    ints2.append(3,4,5,3)
    ints2.appendAll(arr4)
    println(ints2.mkString(","))
    ints2.prepend(12,3,45,56)
    println(ints2.mkString(","))
    ints2.insert(1,4545,56,66)
    println(ints2.mkString(","))
    ints2.remove(1)
    println(ints2.getClass.getSimpleName)
    println(ints2.mkString(","))
    val array: Array[Int] = ints2.toArray
    println(array.getClass.getSimpleName)
    println(array.mkString(","))
  }
}
